package com.wcs.exam.controller.admin;

import com.wcs.exam.common.base.Result;
import com.wcs.exam.common.base.annotation.OptLog;
import com.wcs.exam.common.base.page.Page;
import com.wcs.exam.controller.admin.biz.AdminUsersBiz;
import com.wcs.exam.controller.admin.req.*;
import com.wcs.exam.controller.admin.resp.AdminUsersPageResp;
import com.wcs.exam.controller.admin.resp.AdminUsersViewResp;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

/**
 * Admin-用户信息
 *
 * @author wcs
 * @since 2025-03-13
 */
@Tag(name = "Admin-用户信息")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/admin/users")
public class AdminUsersController {

    @NotNull
    private final AdminUsersBiz biz;

    @Operation(summary = "用户信息-分页")
    @GetMapping(value = "/page")
    public Result<Page<AdminUsersPageResp>> page(@ModelAttribute AdminUsersPageReq req) {
        return biz.page(req);
    }

    @Operation(summary = "用户信息-添加")
    @PostMapping(value = "/save")
    public Result<String> save(@RequestBody @Valid AdminUsersSaveReq req) {
        return biz.save(req);
    }

    @Operation(summary = "用户信息-查看")
    @Parameter(name = "id", description = "主键ID", required = true)
    @GetMapping(value = "/view")
    public Result<AdminUsersViewResp> view(@RequestParam Long id) {
        return biz.view(id);
    }

    @Operation(summary = "用户信息-编辑")
    @PutMapping(value = "/edit")
    public Result<String> edit(@RequestBody @Valid AdminUsersEditReq req) {
        return biz.edit(req);
    }

    @Operation(summary = "用户信息-更新状态")
    @OptLog(value = "用户信息更新状态")
    @PutMapping(value = "/update/status")
    public Result<String> updateStatus(@RequestBody @Valid AdminUsersUpdateStatusReq req) {
        return biz.updateStatus(req);
    }

    @Operation(summary = "用户信息-删除")
    @Parameter(name = "id", description = "主键ID", required = true)
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam Long id) {
        return biz.delete(id);
    }

    @Operation(summary = "用户信息-标签批量记录")
    @OptLog(value = "用户信息-标签批量记录")
    @PostMapping(value = "/tag")
    public Result<String> tag(@RequestBody @Valid AdminUsersTagReq req) {
        return biz.tag(req);
    }

}
